﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace QLKS.Views
{
    /// <summary>
    /// Interaction logic for ucDmNguoiDung.xaml
    /// </summary>
    public partial class ucDmNguoiDung : UserControl
    {
        string columns = "username,tennhuser,tennv,status";
        public ucDmNguoiDung()
        {
            InitializeComponent();
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mainContent.StringBrowse = "username:Tên đăng nhập:200:F;tennhuser:Nhóm:100;tennv:Nhân Viên:200;status:Trạng thái:130";
            //uc = new Views.ucTemplate("Images\\login.png", "DANH SÁCH NGƯỜI DÙNG", ViewModels.NguoiDungViewModel.GetAllNguoiDung(), s, null);
            mainContent.TableSource = ViewModels.NguoiDungViewModel.GetAllNguoiDung(columns);
            //mainContent.F2 += new ucDmTemplate.GridKeyUp_F2(PressKey_F2);//Xem
            mainContent.F4 += new ucDmTemplate.GridKeyUp_F4(PressKey_F4);//Tạo mới
            //mainContent.F3 += new ucDmTemplate.GridKeyUp_F3(PressKey_F3);//Chỉnh sửa
            //mainContent.F6 += new ucDmTemplate.GridKeyUp_F6(PressKey_F6);//Refresh
            //mainContent.F8 += new ucDmTemplate.GridKeyUp_F8(PressKey_F8);//Delete
        }

        //void PressKey_F2(object sender, EventArgs e)
        //{
        //    DataTable tb = mainContent.CurentRow;
        //    if (tb == null)
        //        return;
        //    frmThemNguoiDung frm = new frmThemNguoiDung(tb, Command.View);
        //    frm.Show();
        //}

        //void PressKey_F3(object sender, EventArgs e)
        //{
        //    DataTable tb = mainContent.CurentRow;
        //    if (tb == null)
        //        return;
        //    frmThemNguoiDung frm = new frmThemNguoiDung(tb, Command.Edit);
        //    frm.Show();
        //    if (frm.UpdateSucces)
        //        mainContent.Update(ViewModels.NguoiDungViewModel.GetAllNguoiDung(columns));
        //}
        //void PressKey_F8(object sender, EventArgs e)
        //{
        //    DataTable tb = mainContent.CurentRow;
        //    if (tb == null)
        //        return;
        //    ViewModels.NguoiDungViewModel.XoaNguoiDung(tb.Rows[0]["uswername"].ToString());
        //}
        void PressKey_F4(object sender, EventArgs e)
        {
            frmThemNguoiDung frm = new frmThemNguoiDung(null, Command.New);
            frm.ShowDialog();
            if (frm.UpdateSucces)
                mainContent.Update(ViewModels.NguoiDungViewModel.GetAllNguoiDung(columns));
        }
        //void PressKey_F5(object sender, EventArgs e)
        //{
        //}

        //void PressKey_F6(object sender, EventArgs e)
        //{
        //    mainContent.Update(ViewModels.NguoiDungViewModel.GetAllNguoiDung(columns));
        //}
    }
}
